/**
 * Created by AllanXu on 01/03/2016.
 */
define(function (require) {
	var Vue = require('vue'),
		Config = require('config'),
		_ = require('ajax'),
		utilities = require('utilities');

	var qtid =  sessionStorage.qtid;

	var app = new Vue({
		el: '#enroll_msglist',
		data: {
			renderObj: [],
            showReply:false,
			targetUserId:'',
            publicContent:'',
            pageno: 1
		},
		methods: {
			init: function () {
                _(Config.SERVICE.ACTIVITY.ENROLLMSGLIST+'?id='+qtid+'&pageno='+app.pageno+'&pagesize=10',{}, function (data) {
					app.renderObj = data.pageitems;
				});
			},
            go: function (url) {
                location.href = url;
            },
            // 回留言
            reply: function (id) {
                app.targetUserId = id;
                app.showReply = true;
            },
            hideDialog: function () {
                app.showReply = false;
            },
            sendMsg: function (msgContent) {
                if (app.publicContent.trim() === '') {
                    alert('内容不能为空！');
                    return;
                }
                if(qtid==null){
                    alert("您还未登录");
                    location.href = 'enroll_sign.html?id=' + id;
                    return;
                }
                if (app.mateId == qtid) {
                    alert("不能发送给自己");
                } else {
                    _(Config.SERVICE.ACTIVITY.ENROLLSAYHI + '?enMsg.memberA.id=' + qtid + '&enMsg.memberB.id=' + app.targetUserId + '&enMsg.msg=' + app.publicContent, {}, function (data) {
                        if (data.code == 200) {
                            app.showReply = false;
                            alert("发送成功");
                        }
                    });
                }
            },
		}
	});
	app.init();
});
